<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/></head>
<body>

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<label for="">Name: </label><input type="text" name="fname">
<input type="submit">
</form>
<a href="test.php?name=PHP&age=20">Get methods</a>
<br>
<?php
$x = 5;
$y = 10;
$text1 = "Hello";
$text2 = "World";
$cars = array("Volvo", "BMW", "Toyota");

function myTest() {
    $GLOBALS['y'] = $GLOBALS['x'] + $GLOBALS['y'];
}

myTest();
echo "变量\$y的值为: $y";
echo "<br>";
echo "我的车品牌是 $cars[0]";
echo "<br>";
print $text1." ".$text2;
echo "<br>";
echo $text1,$text2;
echo "<br>";

$name="runoob";
$a=  <<<EOF
"name is $name"
EOF;

// 结束需要独立一行且前后不能空格
echo $a;

echo "<br>";
$booleneg = true;
var_dump($booleneg);
echo "<br>";

class Car {
    var $color;
    var $speed = 24;
    function __construct($color="green")
    {
        $this->color = $color;
    }

    function what_color() {
        return $this->color;
    }
}

function print_vars($obj) {
    foreach (get_object_vars($obj) as $prop => $val) {
        echo "\t$prop = $val\n";
    }
}
$herbie = new Car("white");
echo "\ttherbie: Properties\n";
print_vars($herbie);
echo "<br>";

define("GREETING", "欢迎访问Runndio", true);
echo grEeting;
echo "<br>";
echo strlen("Hello world!");
echo "<br>";
echo strpos("Hello world!", "h");
echo "<br>";

date_default_timezone_set("PRC");
$t=date("H");
var_dump($t);
if ($t<"10")
{
    echo "Have a good morning!";
}
else if ($t<"20")
{
    echo "Have a good day!";
}
else
{
    echo "Have a good night!";
}

$favoriteColor = "red";
switch($favoriteColor) {
    case "red":
    echo "It is same to me";
    break;
    case "blue":
    echo "blue";
    break;
    default:
    echo "oj";
}
echo "<br>";
$age = array("peter"=>35, "Ben"=> 45, "joe"=> "43");
foreach($age as $x => $x_value) {
    echo "key= ".$x.", Value= ".$x_value;
    echo "<br>";
}

$fname = @$_POST["fname"];
echo $fname;


?>
</body>
</html>


